package com.weds.data_sync.util.xxl_component;

import com.xxl.job.core.executor.impl.XxlJobSpringExecutor;
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnSingleCandidate;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Import;
import org.springframework.web.client.RestTemplate;

/**
 * @Description xxl 自动配置
 * @Author lihw
 * @Date 2024/1/18 16:41
 */
// @AutoConfiguration(after = {RestTemplate.class})
@Configuration(proxyBeanMethods = false)
@ConditionalOnBean({XxlJobSpringExecutor.class})
@Import({XxlProperties.class, RestTemplate.class})
public class XxlAutoConfiguration {

    @Bean
    @ConditionalOnMissingBean(name = "xxlTemplate")
    @ConditionalOnSingleCandidate(XxlProperties.class)
    public XxlTemplate xxlTemplate(XxlProperties xxlProperties, RestTemplate restTemplate) {
        return new XxlTemplate(xxlProperties, restTemplate);
    }

}
